﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;

namespace Kang.ExtendMethod.Log
{
    public class Logger : LoggerBase
    {
        public string Name { get; private set; }

        protected internal Logger(string name)
        {
            Name = name;
        }

        public void Debug(Exception exception)
        {
            System.Diagnostics.Debug.WriteLine($"{DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff")} | DEBUG | {exception.Message}");
        }

        public void Debug(string message)
        {
            System.Diagnostics.Debug.WriteLine($"{DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff")} | DEBUG | {message}");
        }

        public void Debug(object message)
        {
            Debug($"{message}");
        }

        public void Error(Exception exception)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | ERROR | {exception.Message}");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"{d} | ERROR | {exception.Message}");
            Console.ResetColor();
        }

        public void Error(string message)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | ERROR | {message}");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"{d} | ERROR | {message}");
            Console.ResetColor();
        }

        public void Error(object message)
        {
            Error($"{message}");
        }

        public void Fatal(Exception exception)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | FATAL | {exception.Message}");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"{d} | FATAL | {exception.Message}");
            Console.ResetColor();
        }

        public void Fatal(string message)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | FATAL | {message}");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"{d} | FATAL | {message}");
            Console.ResetColor();
        }

        public void Fatal(object message)
        {
            Fatal($"{message}");
        }

        public void Info(Exception exception)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | INFO | {exception.Message}");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine($"{d} | INFO | {exception.Message}");
            Console.ResetColor();
        }

        public void Info(string message)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | INFO | {message}");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine($"{d} | INFO | {message}");
            Console.ResetColor();
        }

        public void Info(object message)
        {
            Info($"{message}");
        }

        public void Trace(Exception exception)
        {
            System.Diagnostics.Debug.WriteLine($"{DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff")} | TRACE | {exception.Message}");
        }

        public void Trace(string message)
        {
            System.Diagnostics.Debug.WriteLine($"{DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff")} | TRACE | {message}");
        }

        public void Trace(object message)
        {
            Trace($"{message}");
        }

        public void Warn(Exception exception)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | WARN | {exception.Message}");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine($"{d} | WARN | {exception.Message}");
            Console.ResetColor();
        }

        public void Warn(string message)
        {
            var d = DateTime.Now.GetString("yyyy-MM-dd HH:mm:ss.ffff");
            System.Diagnostics.Debug.WriteLine($"{d} | WARN | {message}");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine($"{d} | WARN | {message}");
            Console.ResetColor();
        }

        public void Warn(object message)
        {
            Warn($"{message}");
        }
    }
}
